<template>
  <div class="box">
    <h2>子组件 add</h2>
    从vuex中获取的值:{{count}}
    <br />
    <button @click="addCount">值+1</button>
    <button @click="change(100)">变成100</button>
    <button @click="changetwo(200)">1秒变成200</button>
  </div>
</template>

<script>
import { mapActions, mapMutations } from 'vuex'
export default {
  name: 'AddItem',
  computed:{
    count(){
      return this.$store.state.count
    }
  },
  methods:{

    ...mapMutations(['addCount']),
    ...mapMutations(['change']),
    ...mapActions(['changetwo'])
  }
}
</script>

<style lang="css" scoped>
.box {
  border: 3px solid #ccc;
  width: 400px;
  padding: 10px;
  margin: 20px;
}
h2 {
  margin-top: 10px;
}
</style>